package com.ruoyi.produce.process.worksheet.mapper;

import com.ruoyi.produce.process.worksheet.domain.ProduceProcedureTransferSheet;
import com.ruoyi.produce.process.worksheet.domain.ProduceWorkSheet;
import com.ruoyi.produce.process.worksheet.domain.ProduceWorkSheetAllocationRecord;
import com.ruoyi.produce.process.worksheet.domain.WorkSheetProcedure;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 加工单
 * 数据层
 * @author Drj 2021/6/28
 */
@Mapper
public interface ProduceWorkSheetMapper {
    /**
     * 查找加工单
     * @param produceWorkSheet
     * @return
     */
    public List<ProduceWorkSheet>selectProduceWorkSheetList(ProduceWorkSheet produceWorkSheet);

    /**
     * 查找正在生产的加工单
     * @param produceWorkSheet
     * @return
     */
    public List<ProduceWorkSheet>selectProcessingProduceWorkSheetList(ProduceWorkSheet produceWorkSheet);

    /**
     * 查找生产完成的加工单
     * @param produceWorkSheet
     * @return
     */
    public List<ProduceWorkSheet>selectFinishedProduceWorkSheetList(ProduceWorkSheet produceWorkSheet);

    /**
     * 根据加工单号查找
     * @param workSheetId 加工单号
     * @return
     */
    public ProduceWorkSheet selectProduceWorkSheetById(String workSheetId);

    /**
     * 根据生产计划号查找
     * @param planSelfId 生产计划号
     * @return
     */
    List<ProduceWorkSheet> selectProduceWorkSheetByPlanSelfId(String planSelfId);

    /**
     * 新增加工单
     * @param produceWorkSheet
     * @return
     */
    public int insertProduceWorkSheet(ProduceWorkSheet produceWorkSheet);

    /**
     * 更新加工单
     * @param produceWorkSheet
     * @return
     */
    public int updateProduceWorkSheet(ProduceWorkSheet produceWorkSheet);

    /**
     * 删除加工单
     * 仅修改加工单删除标志
     * @param produceWorkSheet
     * @return
     */
    public int updateProduceWorkSheetDeleteFlag(ProduceWorkSheet produceWorkSheet);

    /**
     * 更新审批状态
     * @param workSheetId
     * @return
     */
    int completeApprovalFlag(String workSheetId);

    /**
     * 拒绝审批状态
     * @param workSheetId
     * @return
     */
    int refuseApprovalFlag(String workSheetId);


    /**
     * 更新加工单结束时间
     * @param produceWorkSheet
     * @return
     */
    public int updateProduceWorkSheetEndTime(ProduceWorkSheet produceWorkSheet);
    /**
     * 加工单产线分配
     * @param produceWorkSheet
     * @return
     */
    public int updateProduceWorkSheetAllocation(ProduceWorkSheet produceWorkSheet);

    /**
     * 加工单产线分配移除
     * @param produceWorkSheet
     * @return
     */
    public int removeProduceWorkSheetAllocation(ProduceWorkSheet produceWorkSheet);
    /**
     * 查找加工单产线分配记录
     * @param produceWorkSheetAllocationRecord
     * @return
     */
    public List<ProduceWorkSheetAllocationRecord>selectProduceWorkSheetAllocationRecordList(ProduceWorkSheetAllocationRecord produceWorkSheetAllocationRecord);

    /**
     * 新增加工单产线分配
     * @param produceWorkSheetAllocationRecord
     * @return
     */
    public int insertProduceWorkSheetAllocationRecord(ProduceWorkSheetAllocationRecord produceWorkSheetAllocationRecord);

    /**
     * 查找加工单工序移交记录
     * @param produceProcedureTransferSheet
     * @return
     */
    public List<ProduceProcedureTransferSheet> selectProduceProcedureTransferSheetList(ProduceProcedureTransferSheet produceProcedureTransferSheet);


    /**
     * 根据加工单号以及自增序号查找加工单工序移交记录
     * @param workSheetId 加工单号
     * @param increasingId 自增序号
     * @return
     */
    public ProduceProcedureTransferSheet selectProduceProcedureTransferSheetById(@Param("workSheetId")String workSheetId,@Param("increasingId")String increasingId);

    /**
     * 新增加工单工序移交记录
     * @param produceProcedureTransferSheet
     * @return
     */
    public int insertProduceProcedureTransferSheet(ProduceProcedureTransferSheet produceProcedureTransferSheet);

    /**
     * 更新加工单工序移交记录
     * @param produceProcedureTransferSheet
     * @return
     */
    public int updateProduceProcedureTransferSheet(ProduceProcedureTransferSheet produceProcedureTransferSheet);

    /**
     * 确认工序移交记录
     * @param produceProcedureTransferSheet
     * @return
     */
    public int confirmProduceProcedureTransferSheet(ProduceProcedureTransferSheet produceProcedureTransferSheet);

    /**
     * 查询产品所需工序
     * @param produceId
     * @return
     */
    public List<WorkSheetProcedure>selectWorkSheetProcedureList(String produceId);

    /**
     * 获取最新的一条加工单编号
     * @return
     */
    public String getWorkSheetId();

    /**
     * 更新计划结束状态
     * @return
     */
    int updateCompletionStatus(String workSheetId);

}
